<template>
  <!-- 退税结算 -->
  <c-main-template minHeight="auto" :isBreadcrumb="false">
    <el-row :gutter="24" class="pd-lg">
      <el-col :span="7">
        <div class="flex-y-center">
          <div class="mr-lg f-s-14">出口申请单号：</div>
          <el-input
            size="large"
            placeholder="请输入出口申请单号"
            v-model="querys.carInApplyId"
            class="wh flex-1 mr-lg"
          />
        </div>
      </el-col>
      <el-col :span="7">
        <div class="flex-y-center">
          <div class="mr-lg f-s-14">状态：</div>
          <el-select
            v-model="querys.status"
            size="large"
            class="wh flex-1 mr-lg"
            placeholder="请选择状态"
          >
            <el-option
              v-for="item in drawbackType"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </div>
      </el-col>
      <el-col :span="10">
        <div class="flex-x-end">
          <el-button size="large" @click="handleReset">重 置</el-button>
          <el-button size="large" type="primary" @click="handleSelect"
            >查 询</el-button
          >
        </div>
      </el-col>
    </el-row>
  </c-main-template>
  <c-main-template
    v-loading="loading"
    class="mt-lg"
    minHeight="auto"
    title="退税结算"
    :isBreadcrumb="false"
  >
    <c-table-template :data="tableData">
      <el-table-column label="序号" align="center" type="index" width="60" />
      <el-table-column label="出申请单号" prop="carOutApplyId" align="center" />
      <el-table-column label="退税金额(元)" align="center">
        <template #default="scope" >
          <span v-if="scope.row.amount">{{ filters.thousands(scope.row.amount) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="left" width="200">
        <template #default="scope">
          {{ filters.dateYMDHMSFormat(scope.row.timeCreate) }}
        </template>
      </el-table-column>
      <el-table-column label="状态" prop="" align="center" width="150">
        <template #default="scope">
          {{ getStatusLabel(drawbackType, scope.row.status) }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="200">
        <template #default="scope">
          <!-- 平台没有上传billUrl(退税单) 并且 供应商没有选择(sellerBankId)银行 -->
          <el-button
            v-if="scope.row.billUrl && !scope.row.sellerBankId"
            link
            class="mr-sm"
            type="primary"
            size="small"
            @click="handleAffirm(scope.row)"
          >
            <span>确定</span>
          </el-button>
          <el-button
            v-if="scope.row.status === 1 || scope.row.sellerBankId"
            link
            size="small"
            class="mr-sm"
            type="primary"
            @click="handleDetails(scope.row)"
          >
            <span>查看明细</span>
          </el-button>
        </template>
      </el-table-column>
    </c-table-template>
    <div class="flex-x-end pd-20">
      <c-page-template
        :total="total"
        :querys="querys"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </c-main-template>
  <c-drawback-affirm ref="cDrawbackAffirmRef" @change="tableList" />
  <c-drawback-details ref="cDrawbackDetailsRef" />
</template>
<script setup>
import { ref, getCurrentInstance } from "vue";
import { useBasicsTable } from "@/hooks/useTable.js";
import { getStatusLabel, drawbackType } from "@/utils/status.js";
import cDrawbackAffirm from "./components/c-drawback-affirm.vue";
import cDrawbackDetails from "./components/c-drawback-details.vue";
const { proxy } = getCurrentInstance();
const cDrawbackAffirmRef = ref();
const cDrawbackDetailsRef = ref();
const handleAffirm = (item) => {
  cDrawbackAffirmRef.value.handleOpen(item);
};

const handleDetails = (item) => {
  cDrawbackDetailsRef.value.handleOpen(item);
};
const {
  querys,
  tableData,
  total,
  loading,
  tableList,
  handleSelect,
  handleSizeChange,
  handleCurrentChange,
  handleReset,
} = useBasicsTable({
  url: "/sellerTaxRefundList/pageSeller",
});
</script>